package First;

public class NetPackage extends ServicePackage implements NetService {
    int flow;  // 上网流量(MB)
    public NetPackage(double price) {
        this.price = price;
        this.flow = 3*1024;
    }
    @Override
    public void showInfo() {
        System.out.println("网虫套餐:上网流量为" +flow+" MB/月,月租:"+price+"元");
    }
    @Override
    public int netPlay(int flow, MobileCard card) {
        int extra = 0;
        if (flow <= this.flow) {
            this.flow -= flow;
        } else {
            extra = flow - this.flow;
            this.flow = 0;
            // 额外流量按0.1元/MB计费
            card.setConsumAmount(card.getConsumAmount()+extra * 0.1);
        }
        card.setRealFlow(card.getRealFlow()+flow);
        return extra;
    }
    public int getFlow() {
        return flow;
    }
}